package com.guochenglang.www.dao;

import com.guochenglang.www.pojo.Article;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * @author GuoChenglang
 */
public interface ArticleDao {
    /**
     * 搜索文章
     *
     * @param article 搜索的条件
     * @return 搜索的文章
     * @throws SQLException           sql异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实例异常
     * @throws InterruptedException   断点异常
     */
    ArrayList<Article> articleSelect(Article article) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException;

    /**
     * 分页查询
     *
     * @param page    当前页码
     * @param num     当前页面显示的信息个数
     * @param article 搜索条件
     * @param order   排列的条件
     * @param mode    升序还是降序
     * @return 搜素条件
     * @throws SQLException           sql异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实例异常
     * @throws InterruptedException   断点异常
     */
    ArrayList<Article> articleSelectByLimit(int page, int num, Article article, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 创建文章
     *
     * @param article 文章的信息
     * @return 插入后得到的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int insertArticle(Article article) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 更新文章内容
     *
     * @param set        更改后的值
     * @param conditions 更改条件
     * @return 更改执行结果
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int updateArticle(Article set, Article conditions) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 删除文章
     *
     * @param conditions 删除条件
     * @return 删除结果
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int deleteArticle(Article conditions) throws SQLException, InterruptedException, IllegalAccessException;
}
